<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 隐式类型转换  => 浏览器在运算过程中的默认转化机制 

    // 强制类型转换  => 浏览器页提供了将数据强制转换为  number ,string ,boolean的方法

    // Number();     接收一个参数, 将其他类型转化为number类型  => 返回转化后的结果

    // var result = Number("100"); 
    // console.log(result);

    // console.log(Number("100"));  // 100
    // console.log(Number("100a")); // NaN
    // console.log(Number(""));     // "" =>  0
    // console.log(Number("   "));  // " " => 0

    // console.log(Number(true));          // true => 1
    // console.log(Number(false));         // false => 0
    // console.log(Number(null));          // null => 0
    // console.log(Number(undefined));     // undefined => NaN 

    // String , Number , Boolean ,null , undefined 
    // String()    接收一个参数, 将其他类型转化为字符串类型  => 返回转化后的结果

    // typeof typeof 1  => typeof "number"  => "string"

    // var result = String(100);
    // console.log(result,typeof result,typeof typeof 1);

    // console.log(String("100a"));   // "100a"
    // console.log(String(100));   // "100"
    // console.log(String(NaN));   // "NaN"
    // console.log(String(Infinity)); // "Infinity"
    // console.log(String(true)); // "true"
    // console.log(String(null)); // "null"
    // console.log(String(undefined)); // "undefined"

    // 数字转字符串
    // console.log(100);
    // console.log(String(100));
    // console.log('100');
    // console.log(String('100波'));
    // console.log('100波');

    // 布尔值
    // "" 0 NaN null undefined  => 转化为布尔值为false

    // console.log(Boolean("100"));// true
    // console.log(Boolean("100a"));// true
    // console.log(Boolean("asdasdasdasd"));// true
    // console.log(Boolean(""));   // ""  => false
    // console.log(Boolean(" "));  // " " => true

    console.log(Boolean(1));//  ==>true
    console.log(Boolean(-1));//  ==>true
    console.log(Boolean(0));//  ==>false
    console.log(Boolean(NaN));//  ==>false
    console.log(Boolean(Infinity));//  ==>true
    console.log(Boolean(null));//  ==>false
    console.log(Boolean(undefined));//  ==>false
  </script>
</body>

</html>